namespace = IQINS
character_event = {
	id = IQINS.002
	
	hide_window = yes # Only fires for unplayable landless characters
	
	is_triggered_only = yes

	capable_only = yes
	prisoner = no
	
	trigger = {

	}
	
	immediate = {
		
		wealth = 500
		clr_character_flag = do_not_disturb
		
		liege = {
			character_event = {
				id = TOG.1203
				days = 1
			}
		}
		
		liege = {
			capital_scope = {
				ROOT = {
					set_defacto_liege = ROOT
					create_title = {
						tier = DUKE
						landless = yes
						temporary = yes
						adventurer = yes
						culture = ROOT
						name = "CLAIMANT_ADVENTURE"
						holder = ROOT
					}
					
					random_claim = {
						limit = {
							has_holder = yes
							holder_scope = {
								independent = yes # Only do this vs independent rulers
								reverse_has_opinion_modifier = {
									who = ROOT
									modifier = opinion_claimant_adventure_target
								}
								OR = {
									# Don't target my liege unless I am ambitious
									NOT = { is_vassal_or_below = ROOT }
									ROOT = { trait = ambitious }
								}
								OR = {
									is_merchant_republic = no
									NOT = {
										capital_holding = {
											de_jure_liege_or_above = PREVPREV
										}
									}
								}
							}
							OR = {
								tier = KING
								holder_scope = { tier = PREV }
							}
						}
						holder_scope = {
							ROOT = {
								set_character_flag = claimant_adventurer
								random_list = {
									34 = {
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											#leader = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.125
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
									}
									33 = {
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											#leader = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.1
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
									}
									33 = {
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											#leader = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
										spawn_unit = {
											province = PREVPREVPREVPREV
											home = PREVPREVPREVPREV
											owner = THIS
											match_character = PREV
											match_mult = 0.075
											match_min = 300
											match_max = 5000
											attrition = 0.25
											earmark = claimant_adventure
										}
									}
								}
							}
						}
					}
				}
			}
		}
		
		# I no longer have a valid claim on the target
		if = {
			limit = {
				NOT = { has_character_flag = claimant_adventurer }
			}
			break = yes
		}
		
		# Create some decent commander characters
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 33
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 29
		}
		
		# Create a fleet, just to be sure
		spawn_fleet = {
			province = closest # closest sea zone
			owner = ROOT
			disband_on_peace = yes
			troops =
			{
				galleys = { 150 150 }
			}
			earmark = claimant_adventure
		}
		
		random_claim = {
			limit = {
				has_holder = yes
				holder_scope = {
					independent = yes # Only do this vs independent rulers
					NAND = {
						government = nomadic_government
						OR = {
							clan_title = {
								title = PREVPREV
							}
							primary_title = {
								title = PREVPREV
							}
						}
					}
					reverse_has_opinion_modifier = {
						who = ROOT
						modifier = opinion_claimant_adventure_target
					}
					OR = {
						# Don't target my liege unless I am ambitious
						NOT = { is_vassal_or_below = ROOT }
						ROOT = { trait = ambitious }
					}
					OR = {
						is_merchant_republic = no
						NOT = {
							capital_holding = {
								de_jure_liege_or_above = PREVPREV
							}
						}
					}
				}
				OR = {
					tier = KING
					holder_scope = { tier = PREV }
				}
			}
			
#			log = "TOG.1202: [Root.GetBestName] starts claim adventure for [This.GetName]"
			
			holder_scope = {
				reverse_unsafe_war = {
					target = ROOT
					casus_belli = claim
					thirdparty_title = PREV
				}
				reverse_remove_opinion = {
					who = ROOT
					modifier = opinion_claimant_adventure_target
				}
			}
		}
	}
	
	option = {
		name = OK
	}
}